package com.fla.millioner.ui.support;

import com.danikula.aibolit.Aibolit;
import com.danikula.aibolit.annotation.InjectView;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.alone1672.millioner.R;
public class AnswerView extends LinearLayout {

    @InjectView(R.id.letterTextView)
    private TextView letterTextView;

    @InjectView(R.id.answerTextView)
    private TextView answerTextView;

    public AnswerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs);
    }

    public AnswerView(Context context) {
        super(context);
        init(null);
    }

    private void init(AttributeSet attrs) {
        LayoutInflater.from(getContext()).inflate(R.layout.answer_view, this);
        Aibolit.doInjections(this);
        setClickable(true);
        setBackgroundResource(R.drawable.answer);

        if (attrs != null) {
            letterTextView.setText("♦" + attrs.getAttributeValue(null, "letter") + ":");
        }
    }
    
    public void setTextSize(float fontSize) {
        letterTextView.setTextSize(fontSize);
        answerTextView.setTextSize(fontSize);
    }

    public void setAnswer(String text) {
        answerTextView.setText(text);
    }
    
    public String getAnswer() {
        return answerTextView.getText().toString();
    }

    public void makeDefault() {
        setBackgroundResource(R.drawable.answer);
        makeAnswerWhite();
    }

    public void makeYellow() {
        setBackgroundResource(R.drawable.answer_yellow_shape);
        makeAnswerBlack();
    }

    public void makeGreen() {
        setBackgroundResource(R.drawable.answer_green_shape);
        makeAnswerBlack();
    }

    public void makeRed() {
        setBackgroundResource(R.drawable.answer_red_shape);
        makeAnswerBlack();
    }

    private void makeAnswerBlack() {
        answerTextView.setTextColor(Color.BLACK);
    }

    private void makeAnswerWhite() {
        answerTextView.setTextColor(Color.WHITE);
    }
}
